package com.lagou.rpc;

import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToMessageDecoder;

import java.util.List;

public class RpcDecoder2 extends MessageToMessageDecoder<String> {

    private Class<?> clazz;
    private Serializer serializer;

    public RpcDecoder2(Class<?> clazz, Serializer serializer) {
        this.clazz = clazz;
        this.serializer = serializer;
    }

    protected void decode(ChannelHandlerContext ctx, String msg, List<Object> out) throws Exception {
        System.out.println("RpcDecoder2 解码"+msg);
        out.add(serializer.deserialize(clazz, msg.getBytes()));
    }
}
